# -*- coding: utf-8 -*-
#intro

import pyglet
from pyglet import event

import camera

class Intro(event.EventDispatcher):
    def __init__(self, parent):
        self.parent = parent
        self.parent.push_handlers(self)
        self.nr = 0
        self.images = [pyglet.resource.image(str(n) + ".png") for n in xrange(1,8)]
        #for img in self.images:
            #img.anchor_y = self.parent.height - img.height
            #img.anchor_x = self.parent.width - img.width
        self.cam = camera.Camera((self.images[0].width/2, self.images[0].height/2), scale=250)

    
    def on_draw(self):
        self.parent.clear() #jättehack
        self.cam.focus(self.parent.width, self.parent.height)
        self.images[self.nr].blit(0,0)
        return event.EVENT_HANDLED

    def on_key_press(self, symbol, modifier):
        self.nr += 1
        if self.nr > 7:
            self.parent.remove_handlers(self)
        return event.EVENT_HANDLED